# 环形链表2


# 这一题太神奇了

class Solution:

    def detectCycle(self, head):

        slow = fast = head
        while fast and fast.next:

            slow = slow.next
            fast = fast.next.next

            if fast is slow:
                while slow is not head:
                    # 在走a步两个人会相同
                    slow = slow.next
                    head = head.next
                
                return slow
        
        return None


